<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>提问_狼窝窝问答</title>
    <meta name="viewport"
          content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no,minimal-ui,viewport-fit=cover"/>
    <meta name="copyright" content="Copyright (c) 2006-2019 Mafengwo."/>
    <meta name="format-detection" content="telephone=no,address=no"/>
    <meta name="referrer" content="always"/>
    <link href="/css/question/mobile+css+head_mobile+css+ui.css"
          rel="stylesheet" type="text/css">
    <link href="https://css.mafengwo.net/mobile/css/ask/ask.css?1550829726" rel="stylesheet" type="text/css"/>
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <script src="/js/plugins/form/jquery.form.js"></script>
    <script src="/js/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css">
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script src="/js/common.js"></script>
    <script src="/js/checkLogin.js"></script>
    <script>
        $(function () {
            //点击发布问题提交问题表单
            $("#publish").click(function () {
                if ($("#questionTitle").val().length < 10) {
                    $(document).dialog({
                        type: 'notice',
                        content: '<span class="info-text">内容不能小于10个字</span>',
                        autoClose: 1000,
                        position: 'bottom'
                    });
                } else if ("" == $("#questionPlace").val() || $("#questionPlace").val() == null) {
                    $(document).dialog({
                        type: 'notice',
                        content: '<span class="info-text">目的地不能为空</span>',
                        autoClose: 1000,
                        position: 'bottom'
                    });
                } else {
                    $("#questionEditor").ajaxSubmit({
                        url: baseUrl + "/questions",
                    });
                    //跳转到问题列表
                    window.location.href = "/questionPage.html";
                }
            });
            // 利用文件框的值改变事件
            $("#fileInput").change(function () {
                if ($(this).val()) { // 有值才提交
                    // 浏览器获得的value值是一个fake值，假的路径，所以需要
                    // 利用表单来提交，表单中是真实的路径。
                    $("#fileForm").ajaxSubmit({
                        url: baseUrl + "/images",
                        success: function (data) {
                            if (data.status == 1) {
                                $("#coverUrl").attr('src', data.url);
                                $("#questionImgUrl").val(data.url);
                            }
                        }
                    });
                }
            });
            // 点击更换封面
            $("#changeBtn").click(function () {
                $("#fileInput").click();
            });
        })

    </script>

</head>
<body>
<form id="fileForm" method="post">
    <input type="file" name="file" id="fileInput" style="display: none">
</form>
<div id="pos38"></div>
<header class="head2home">
    <a href="/" class="logo">
        <img src="/img/logo/logo.png" width="100%">
    </a>
    <div class="rBtn">
        <a href="/index.html" class="home">首页</a>
    </div>
</header>


<section class="Addnew">
    <form id="questionEditor" method="post">
        <div id="_j_publish_box" class="ask_tan_con">
            <dl>
                <dd class="_j_word">
                    <input name="title" id="questionTitle" class="_j_q_title _j_word_check"
                           placeholder="请输入你的问题，不少于10个字哦">
                    <div class="err-tips" style="display: none;"></div>
                </dd>
            </dl>
            <dl>
                <dt>问题说明（可选）</dt>
                <dd class="con_textarea _j_word" id="con_textarea">
                    <textarea name="questionContent" rows=1 id="pnl_textarea"
                              class="_j_q_content _j_word_check"></textarea>
                </dd>
            </dl>
            <dl>
                <dt>填写目的地</dt>
                <dd>
                    <input style="text-indent:35px;" id="questionPlace" class="_j_q_mddname" name="questionPlace">
                    <ul class=" _j_mdd_suggest" style="display:none;"></ul>
                    <i class="loc"></i>
                </dd>
            </dl>
            <dl>
                <dt>上传提问图片</dt>
                <dd>
                    <img id="coverUrl" width="100%" height="200px"/>
                    <div align="center">
                        <button type="button" class="btn" id="changeBtn">
                            <i class="fa fa-cloud-upload"></i>
                            <middle>上传</middle>
                            <input type="hidden" name="questionImgUrl" id="questionImgUrl">
                        </button>
                    </div>
                </dd>
            </dl>
            <dl>
                <dd>
                    <a class="_j_publish_question" id="publish">发布问题</a>
                </dd>
            </dl>
        </div>
    </form>
</section>


<script language="javascript" type="text/javascript">
    if (typeof M !== "undefined" && typeof M.loadResource === "function") {
        M.loadResource("https://js.mafengwo.net/js/cv/mobile+js+BindMobilePop:mobile+js+wenda+common_v2:mobile+js+Pop:mobile+js+wenda+mQPublish:mobile+js+ALogin:js+ACnzzGaLog:js+ARecruit:js+ALazyLoad:mobile+js+wakeApp:mobile+js+omc.global^Yl1X^1558975785.js");
    }
</script>

</body>
</html>
